Documentation for Users  2.1.2
Perception Toolbox for Virtual Reality (PTVR) Manual
2.0_one_scene_w_NON_simplified_duration.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 '''
3 ...\PTVR_Researchers\Python_Scripts\Demos\Scenes\2.0_one_scene_w_NON_simplified_duration.py
4 
5 Description : displays one scene whose duration is defined by explicitely creating an
6  interaction corresponding to this scene.
7  It requires therefore to define an event, a callback and their interaction.
8 
9 """
10 
11 
12 Created on : Thu Jan 13 15:09:02 2022
13 @author: jtermozm
14 
15 '''
16 
17 import PTVR.SystemUtils
18 import numpy as np
19 import PTVR.Visual as visual
23 import PTVR.Data.Event as event
24 import PTVR.Data.Callback as callback
25 
26 # =============================================================================
27 # PARAMETERS #
28 # =============================================================================
29 username = "Julia" # subject's name
30 
31 my_scene_duration_in_ms = 10000 #in Ms
32 # 100 ms corresponds to 9 frames with a refresh rate of 90 Hz (HTC Vive Pro)
33 
34 # =============================================================================
35 # END PARAMETERS #
36 # =============================================================================
37 
38 def main():
39 
40  my_world = visual.The3DWorld (name_of_subject = username)
42 
43  # display Scene information on subject's screen
44  my_text = PTVR.Stimuli.Objects.Text ( text = "This single scene lasts " + str( my_scene_duration_in_ms) + " ms\n" +
45  "and then the script will QUIT PTVR (ie the PTVR window will close itself)\n" +
46  "Or you can quit by closing yourself the PTVR window (mouse click in the top right corner)",
47  position_in_current_CS = np.array([0, 1, 1]), visual_angle_of_centered_x_height_deg = 1,
48  vertical_alignment="baseline")
49  my_scene.place(my_text,my_world)
50 
51  my_event = event.Timer (delay_in_ms = my_scene_duration_in_ms)
52  my_callback = callback.EndCurrentScene()
53 
54  my_scene.AddInteraction ( events = [my_event], callbacks = [my_callback] )
55 
56  my_world.add_scene (my_scene)
57  my_world.write() # Write The3DWorld to .json file
58 
59 
60 if __name__ == "__main__":
61  main()
def LaunchThe3DWorld(jsonFileCategory="Externals")
Definition: SystemUtils.py:182